- Licensed under the GNU AGPL version 3 or higher.
-}
-{-# LANGUAGE CPP #-}
-
module Annex.ReplaceFile (
replaceGitAnnexDirFile,
replaceGitDirFile,
replaceFile' :: (RawFilePath -> Annex ()) -> RawFilePath -> (a -> Bool) -> (RawFilePath -> Annex a) -> Annex a
replaceFile' createdirectory file checkres action = withOtherTmp $ \othertmpdir -> do
-#ifndef mingw32_HOST_OS
let basetmp = relatedTemplate' (P.takeFileName file)
-#else
- let basetmp = toRawFilePath "t"
-#endif
withTmpDirIn (fromRawFilePath othertmpdir) (toOsPath basetmp) $ \tmpdir -> do
let tmpfile = toRawFilePath tmpdir P.</> basetmp
r <- action tmpfile
-}
{-# LANGUAGE OverloadedStrings #-}
+{-# LANGUAGE CPP #-}
{-# OPTIONS_GHC -fno-warn-tabs #-}
module Utility.Tmp (
relatedTemplate = toOsPath . relatedTemplate'
relatedTemplate' :: RawFilePath -> RawFilePath
+#ifndef mingw32_HOST_OS
relatedTemplate' f
| len > templateAddedLength =
{- Some filesystems like FAT have issues with filenames
where
len = B.length f
dot = fromIntegral (ord '.')
+#else
+-- Avoids a test suite failure on windows, reason unknown, but
+-- best to keep paths short on windows anyway.
+relatedTemplate' _ = "t"
+#endif
{- When a Template is used to create a temporary file, some random bytes
- are appended to it. This is how many such bytes can be added, maximum.